//
//  Entities.m
//  FilamentDemo
//
//  Created by jerry on 2020/2/28.
//  Copyright © 2020 jerry. All rights reserved.
//

#import "Entities.h"
#import "FilamentConvenientHeader.h"
#import <simd/simd.h>
#include <list>
#include <map>
	

MyPlaneEntity::MyPlaneEntity(){
    
}
MyPlaneEntity::~MyPlaneEntity(){
    delete boundaryVertexs;
    delete boundaryIndices;
}

TrianglesEntityDatasource::TrianglesEntityDatasource(){
    
}
TrianglesEntityDatasource::~TrianglesEntityDatasource(){
    if (vertexs != nullptr) {
        delete vertexs;
        vertexs = nullptr;
    }
    
    if (indices != nullptr) {
        delete indices;
        indices = nullptr;
    }
    
    if (tagnets != nullptr) {
        delete tagnets;
        tagnets = nullptr;
    }
    
    if (uv != nullptr) {
        delete uv;
        uv = nullptr;
    }
}

MyLineEntity::MyLineEntity(){
    
}
MyLineEntity::~MyLineEntity(){
    if (vertexs != nullptr) {
        delete vertexs;
        vertexs = nullptr;
    }
    
    if (indices != nullptr) {
        delete indices;
        indices = nullptr;
    }
}

LineEntityDataSource::LineEntityDataSource(filament::math::float3 *vertexs, uint16_t verCount){
    indexCount = (verCount - 1) * 2;
    indices = new uint16_t[indexCount];
    this->vertexs = vertexs;
    this->verCount = verCount;
    for (NSInteger i = 0; i < verCount - 1; i++) {
        indices[i * 2] = (uint16_t)i;
        indices[i * 2 + 1] = (uint16_t)i + 1;
    }
}
LineEntityDataSource::~LineEntityDataSource(){
    if (vertexs != nullptr) {
        delete vertexs;
        vertexs = nullptr;
    }
    if (indices != nullptr) {
        delete indices;
        indices = nullptr;
    }
}

ShadowablePlaneEntityInfo::ShadowablePlaneEntityInfo(){
    
}

ShadowablePlaneEntityInfo::~ShadowablePlaneEntityInfo(){
    if (triangleIndices != nullptr) {
        delete triangleIndices;
        triangleIndices = nullptr;
    }
    
    if (tangents != nullptr) {
        delete tangents;
        tangents = nullptr;
    }
    
    //ljflag 语法问题
//    if (matInstance != nullptr) {
//        delete matInstance;
//        matInstance = nullptr;
//    }
}



GlbEntityInfo::GlbEntityInfo(){
    
}

GlbEntityInfo::~GlbEntityInfo(){
    
}
